package com.example.signdemo.controllers;

import com.example.core.libs.JSONResult;
import com.example.signdemo.services.IUserSignLService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/l")
public class SignLController {
    @Autowired
    IUserSignLService userSignLService;

    @RequestMapping("/sign")
    public JSONResult sign(@RequestParam long userId) {
        userSignLService.sign(userId);
        return new JSONResult("签到成功");
    }

    @RequestMapping("/againSign")
    public JSONResult againSign(@RequestParam long userId, @RequestParam String day) {
        userSignLService.againSign(userId, day);
        return new JSONResult("补签成功");
    }

    @RequestMapping("/signDays")
    public JSONResult signDays(@RequestParam long userId) {
        return new JSONResult().put("count", userSignLService.signDays(userId));
    }
}
